package justcommunicate;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;

public abstract class SocketServer {
	public static final int SERVER_PORT = 4444;
	public static final String SERVER_IP = "172.20.230.27";
	public void start() {
		try {
			ServerSocket socket = new ServerSocket(SERVER_PORT);
			while(true) {
				Socket client = socket.accept();
				
				SocketAddress clientAddress = client.getRemoteSocketAddress();
				System.out.println("Handling client at: " + clientAddress);
				InputStream in = client.getInputStream();
				display(in);
				client.close();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	protected abstract void display(InputStream in);
}
